import { reactive } from "vue";
import type { FormRules } from "element-plus";

/** 自定义表单规则校验 */
export const formRules = reactive(<FormRules>{
	nickname: [{ required: true, message: "用户昵称为必填项", trigger: "blur" }],
	username: [{ required: true, message: "用户名称为必填项", trigger: "blur" }],
	password: [{ required: true, message: "用户密码为必填项", trigger: "blur" }],
	phoneNumber: [
		{
			validator: (rule, value, callback) => {
				if (value === "") {
					callback();
				} else {
					callback();
				}
			},
			trigger: "blur"
			// trigger: "click" // 如果想在点击确定按钮时触发这个校验，trigger 设置成 click 即可
		}
	],
	email: [
		{
			validator: (rule, value, callback) => {
				if (value === "") {
					callback();
				} else {
					callback();
				}
			},
			trigger: "blur"
		}
	]
});
